<template>
	<view >
		<u-toast ref="uToast"></u-toast>
		<nuoyu-login @login="Login"></nuoyu-login>
	</view>
</template>

<script>
 
	export default {
		onLoad() {
			
			if(uni.getStorageSync('userInfo')){
				this.$store.state.current = 0
				uni.reLaunch({
					url:'/pages/tabbar/index'
				})
			}
		},
		methods:{
			Login(item,status){
				item.status = status
				this.tui.request("/basic-capi/h5login", "post", item).then((res) => {
					if(res.code == 200){
						uni.setStorageSync('userInfo',res.data.userInfo)
						 this.$refs.uToast.show({
							   type: "default",
							   title: "默认主题",
							   message: "登录成功!",
							   // iconUrl: "https://xxx.com/demo/toast/default.png",
						 });
						 setTimeout(()=>{
							 this.$store.state.current = 0
							 uni.reLaunch({
							 	url:'/pages/tabbar/index'
							 })
						 },200)
						
					}
				}).catch((res) => {
					console.log(res)
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	
</style>
